package com.mostromas.ess.project.feign;


import com.mostromas.ess.entities.UserProject;
import com.mostromas.ess.feign.IFeignProjectController;
import com.mostromas.ess.project.req.UserProjectsREQ;
import com.mostromas.ess.project.service.IUserProjectsService;
import com.mostromas.ess.util.aliyun.AliyunUtil;
import com.mostromas.ess.util.base.Result;
import com.mostromas.ess.util.enums.PlatformEnum;
import com.mostromas.ess.util.properies.OSSProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
public class FeignProjectController implements IFeignProjectController {

    @Autowired
    private OSSProperties ossProperties;
    @Autowired
    private IUserProjectsService userProjectsService;

    @Override
    public Result updateEffectiveTime(@RequestBody UserProject info) {
        return userProjectsService.updateEffectiveTime(info);
    }

    @Override
    public int checkProjectIdHardwareCoding(String projectId,String hardwareCoding) {
        return userProjectsService.checkRegister(projectId,hardwareCoding);
    }

    @Override
    public UserProject getUserProject(String username,String projectId,String hardwareCoding) {

        return userProjectsService.checkLogin(username,projectId,hardwareCoding);
    }


    @Override
    public List<UserProject> getProjectsByUsername(String username) {
        return userProjectsService.getProjectsByUsername(username);
    }
    @Override
    public Result upload(MultipartFile file) {
        return AliyunUtil.uploadFileToOss(PlatformEnum.PROJECT, file, ossProperties.getAliyun());
    }

    @Override
    public Result delete(String fileUrl) {
        return AliyunUtil.delete(fileUrl, ossProperties.getAliyun());
    }
}